let Main = {
    data(){
        return {
            cs: {
                xl: {span:4,offset:10},
                lg: {span:6,offset:9},
                md: {span:6,offset:9},
                sm: {span:10,offset:6},
                xs: {span:20,offset:2}
            },
            form: {
                username: '',
                password: ''
            },
            rules: {
                username: [
                    { required: true, message: '请输入用户名', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: '请输入密码', trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
        submitForm(){
            this.$refs['form'].validate((valid)=>{
                if(valid){
                    let params = new URLSearchParams();
                    params.append('username',this.form.username);
                    params.append('password',this.form.password);
                    axios({
                        method: 'post',
                        url: '/my/login',
                        data: params,
                        headers: {
                            'Content-type': 'application/x-www-form-urlencoded'
                        }
                    })
                    .then(res=>{
                        if(res.data.code==0){
                            this.$message({
                                message: '登录成功',
                                type: 'success'
                            });
                            window.location.href='/my/list'
                        }else{
                            this.$message({
                                message: res.data.msg,
                                type: 'error'
                            });
                        }
                    })
                }
            });
        }
    }
}

let Bone = Vue.extend(Main);
new Bone().$mount('#app');